<template>
  <div class="newsinfo-container">
    <h3 class="title">{{newsinfo.title}}</h3>
    <div class="news-info">
      <span>发布时间: {{ newsinfo.add_time | dateFromat }}</span>
      <span>点击次数: {{ newsinfo.click }}</span>
    </div>
    <hr />
    <div class="content" v-html="newsinfo.content"></div>
    <mt-comment :newsid='id'></mt-comment>
  </div>
</template>

<script>
import MtComment from '../sub-components/Comment.vue'
export default {
  components: {
    MtComment
  },
  created() {
    // 获取新闻详情
    this.__getNewsInfo();
  },
  props: ["id"],
  data() {
    return {
      newsinfo: {} // 新闻详情信息
    };
  },
  methods: {
    // ====================== 网络请求 =======================
    async __getNewsInfo() {
      const { data: res } = await this.$http.get(`getnew/${this.id}`);
      if (res.status !== 0) return;
      this.newsinfo = res.message[0];
    }
  }
};
</script>

<style scoped lang='scss'>
.newsinfo-container {
  padding: 0 5px;
  .title {
    font-size: 15px;
    color: red;
    text-align: center;
    padding: 10px 0;
  }
  .news-info {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #26a2ff;
  }
}
</style>